package cn.bugio.springcloud.controller;

import cn.bugio.springcloud.entity.Student;
import cn.bugio.springcloud.feign.FeignProviderClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Collection;

@RestController
@RequestMapping("/feign")
public class FeignHandler {
    @Autowired
    private FeignProviderClient feignProviderClient;

    @GetMapping("/student/findAll")
    public Collection<Student> findAll() {
        return feignProviderClient.findAll();
    }
    @GetMapping("/student/findById")
    public Student findById(@PathVariable("id") long id) {
        return feignProviderClient.findById(id);
    }
    @PostMapping("/student/save")
    public void save(@RequestBody Student student){
        feignProviderClient.save(student);
    }
    @PutMapping("/student/update")
    public void update(@RequestBody Student student){
        feignProviderClient.update(student);
    }
    @DeleteMapping("/student/deleteById/{id}")
    public void deleteById(@PathVariable("id") long id){
        feignProviderClient.deleteById(id);
    }
    @GetMapping("/student/index")
    public String index(){
        return feignProviderClient.index();
    }
}
